package com.petrochina.cloudconfig.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebAppConfig extends WebMvcConfigurerAdapter{
	
	
	@Autowired
    private StringRedisTemplate stringRedisTemplate;


    
   
	/**
     * 配置拦截器
     * @author lance
     * @param registry
     */
    public void addInterceptors(InterceptorRegistry registry) {
    	/*registry.addInterceptor(new HandlerInterceptor() {
			
			@Override
			public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception {
				boolean canPass = false;
				String sessionToken = request.getParameter("sessionToken");
				if(sessionToken!=null){
					SessionUser sessionUser = sessionMap.getSession(sessionToken);
					if(sessionUser!=null){
						canPass = true;
					}
				}
				return canPass;
			}
			
			@Override
			public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
					throws Exception {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object arg2, Exception arg3)
					throws Exception {
				sessionMap.updateSession(request.getParameter("sessionToken"));
				
			}
		}).addPathPatterns("/user/**");*/
	}

}
